package net.trustie.downloader;

import java.util.LinkedList;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import extension.RawPage;


public interface PageDao {

	@Select("select id,url,html,crawledTime from ${table} where id>= ${begin_id} limit ${interval}" )
	public LinkedList<RawPage> selectScourcePage(@Param("table") String table_name,
			@Param("begin_id") int begin_id, @Param("interval") int interval);

	@Select("select Min(id) from ${table_name}")
	public int getMinId(@Param("table_name") String table_name);	
	
	@Select("select Max(id) from ${table_name}")
	public int getMaxId(@Param("table_name") String table_name);
	
	@Select("select id,url,html,crawledTime from ${table} where id> ${begin_id} limit ${interval}" )
	public LinkedList<RawPage> getDetailPages(@Param("table") String table_name,
			@Param("begin_id") int begin_id, @Param("interval") int interval);

	
//	@Select("select MAX(id) FROM ${table_name} where id in (SELECT t.id FROM (SELECT id FROM ${table_name} WHERE id >${begin_id} limit #{interval}) AS t);")
//	public int getMaxBeginId(@Param("table_name")String table_name,@Param("begin_id") int begin_id, @Param("interval") int interval);
	
}
